//
//  RootVIew.m
//  测试
//
//  Created by dllo on 15/11/12.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "RootVIew.h"
@implementation RootVIew

//- (instancetype)initWithFrame:(CGRect)frame
//{
//    self = [super initWithFrame:frame];
//    if (self) {
//        [self createSubviews];
//    }
//    return self;
//}
//- (void)createSubviews {
//    //设置背景
//    UIImageView *viewV = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//    viewV.image = [UIImage imageNamed:@"angry_00.jpg"];
//    [self addSubview:viewV];
//    [viewV release];
//    //设置四个按钮
//    UIButton *but1 = [UIButton buttonWithType:UIButtonTypeCustom];
//    but1.frame = CGRectMake(20, 500, 60, 60);
//    [but1 setImage:[UIImage imageNamed:@"cymbal.png"] forState:UIControlStateNormal];
//    [but1 addTarget:self action:@selector(Action1:) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:but1];
//    UIButton *but2 = [UIButton buttonWithType:UIButtonTypeCustom];
//    but2.frame = CGRectMake(but1.frame.origin.x, but1.frame.origin.y + but1.frame.size.height + 10, but1.frame.size.width, but1.frame.size.height);
//    [but2 setImage:[UIImage imageNamed:@"drink.png"] forState:UIControlStateNormal];
//    [but2 addTarget:self action:@selector(Action2:) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:but2];
//    UIButton *but3 = [UIButton buttonWithType:UIButtonTypeCustom];
//    but3.frame = CGRectMake(self.frame.size.width  - but1.frame.size.width - but1.frame.origin.x, but1.frame.origin.y, but1.frame.size.width, but1.frame.size.height);
//    [but3 setImage:[UIImage imageNamed:@"eat.png"] forState:UIControlStateNormal];
//    [but3 addTarget:self action:@selector(Action3:) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:but3];
//    UIButton *but4 = [UIButton buttonWithType:UIButtonTypeCustom];
//    but4.frame = CGRectMake(but3.frame.origin.x, but3.frame.origin.y + but3.frame.size.height + 10, but1.frame.size.width, but1.frame.size.height);
//    [but4 setImage:[UIImage imageNamed:@"pie.png"] forState:UIControlStateNormal];
//    [but4 addTarget:self action:@selector(Action4:) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:but4];
//}
//- (void)Action1:(UIButton *) sender {
//    NSMutableArray *arr = [NSMutableArray array];
//    for (NSInteger i = 0; i < 13; i++) {
//        NSString *fileName = [NSString stringWithFormat:@"cymbal_%02ld.jpg", i];
//        UIImage *image = [UIImage imageNamed:fileName];
//        [arr addObject:image];
//    }
//    self.imageV = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//    self.imageV.animationImages = arr;
//    self.imageV.animationRepeatCount = 1;
//    self.imageV.animationDuration = 2;
//    [self addSubview:self.imageV];
//    [self.imageV startAnimating];
//    [_imageV release];
//}
//- (void)Action2:(UIButton *) sender {
//    NSMutableArray *arr = [NSMutableArray array];
//    for (NSInteger i = 0; i < 81; i++) {
//        NSString *fileName = [NSString stringWithFormat:@"drink_%02ld.jpg", i];
//        UIImage *image = [UIImage imageNamed:fileName];
//        [arr addObject:image];
//    }
//    self.imageV = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//    self.imageV.animationImages = arr;
//    self.imageV.animationRepeatCount = 1;
//    self.imageV.animationDuration = 8;
//    [self addSubview:self.imageV];
//    [self.imageV startAnimating];
//    [_imageV release];
//    
//}
//- (void)Action3:(UIButton *) sender {
//    NSMutableArray *arr = [NSMutableArray array];
//    for (NSInteger i = 0; i < 40; i++) {
//        NSString *fileName = [NSString stringWithFormat:@"eat_%02ld.jpg", i];
//        UIImage *image = [UIImage imageNamed:fileName];
//        [arr addObject:image];
//    }
//    self.imageV = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//    self.imageV.animationImages = arr;
//    self.imageV.animationRepeatCount = 1;
//    self.imageV.animationDuration = 2;
//    [self addSubview:self.imageV];
//    [self.imageV startAnimating];
//    [_imageV release];
//    
//}
//- (void)Action4:(UIButton *) sender {
//    NSMutableArray *arr = [NSMutableArray array];
//    for (NSInteger i = 0; i < 24; i++) {
//        NSString *fileName = [NSString stringWithFormat:@"pie_%02ld.jpg", i];
//        UIImage *image = [UIImage imageNamed:fileName];
//        [arr addObject:image];
//    }
//    self.imageV = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//    self.imageV.animationImages = arr;
//    self.imageV.animationRepeatCount = 1;
//    self.imageV.animationDuration = 2;
//    [self addSubview:self.imageV];
//    [self.imageV startAnimating];
//    [_imageV release];
//    
//}
//- (void)dealloc
//{
//    [_slider release];
//    [super dealloc];
//}
//- (instancetype)initWithFrame:(CGRect)frame
//{
//    self = [super initWithFrame:frame];
//    if (self) {
//        [self create];
//    }
//    return self;
//}
//- (void)create {
//    self.slider = [[UISlider alloc] init];
//    self.slider.frame = CGRectMake(20, 20, self.frame.size.width - 40, 30);
//    self.slider.minimumTrackTintColor = [UIColor blueColor];
//    self.slider.maximumTrackTintColor = [UIColor redColor];
//    self.slider.thumbTintColor = [UIColor blackColor];
//    self.slider.maximumValue = 2.0;
//    [self.slider addTarget:self action:@selector(SliderAction:) forControlEvents:UIControlEventValueChanged];
//    [self addSubview:self.slider];
//    [_slider release];
//    self.backgroundColor = [UIColor whiteColor];
//    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 275, 557)];
//    self.imageV.backgroundColor = [UIColor whiteColor];
//    NSMutableArray *Arr = [NSMutableArray array];
//    for (NSInteger i = 0; i < 22; i++) {
//        NSString *fileName = [NSString stringWithFormat:@"Zombie%ld.tiff", i];
//        UIImage *image = [UIImage imageNamed:fileName];
//        [Arr addObject:image];
//    }
//   
//    
//    self.imageV.animationImages = Arr;
//    self.imageV.image = [UIImage imageNamed:@"Zombie0.tiff"];
//    self.imageV.animationDuration = self.slider.maximumValue - self.slider.value;
//    [self addSubview:self.imageV];
//    [self.imageV startAnimating];
//    [_imageV release];
//    
//    
//    UIButton *buttonStop = [UIButton buttonWithType:UIButtonTypeCustom];
//    buttonStop.frame = CGRectMake(20, 60, 40, 40);
//    buttonStop.backgroundColor = [UIColor blueColor];
//    [buttonStop setTitle:@"停止" forState:UIControlStateNormal];
//    [buttonStop addTarget:self action:@selector(ButtonActionStop:) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:buttonStop];
//    
//    UIButton *buttonStart = [UIButton buttonWithType:UIButtonTypeCustom];
//    buttonStart.frame = CGRectMake(80, 60, 40, 40);
//    buttonStart.backgroundColor = [UIColor blueColor];
//    [buttonStart setTitle:@"开始" forState:UIControlStateNormal];
//    [buttonStart addTarget:self action:@selector(ButtonActionStart:) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:buttonStart];
//    
//   
//}
//- (void)SliderAction:(UISlider *)sender {
//    self.imageV.animationDuration = (self.slider.maximumValue - sender.value + 0.01);
//    [self.imageV startAnimating];
//}
//- (void)ButtonActionStart:(UIButton *)sender {
//    [self.imageV startAnimating];
//}
//- (void)ButtonActionStop:(UIButton *)sender {
//    [self.imageV stopAnimating];
//}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self create];
    }
    return self;
}
- (void) create {
    UIView *view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    view.backgroundColor = [UIColor whiteColor];
    //view.backgroundColor = [UIColor colorWithRed:<#(CGFloat)#> green:<#(CGFloat)#> blue:<#(CGFloat)#> alpha:1.0];
//    self.slider1 = [[UISlider alloc] initWithFrame:CGRectMake(20, 100, self.frame.size.width - 40, 30)];
//    self.slider1.thumbTintColor = [UIColor redColor];
//    [self.slider1 addTarget:self action:@selector(Action:) forControlEvents:UIControlEventValueChanged];
//    [self addSubview: self.slider1];
    self.slider2 = [[UISlider alloc] initWithFrame:CGRectMake(20, 200, self.frame.size.width - 40, 30)];
    self.slider2.thumbTintColor = [UIColor greenColor];
    [self.slider2 addTarget:self action:@selector(Action:) forControlEvents:UIControlEventValueChanged];
    [self addSubview: self.slider2];
    self.slider3 = [[UISlider alloc] initWithFrame:CGRectMake(20, 300, self.frame.size.width - 40, 30)];
    self.slider3.thumbTintColor = [UIColor blueColor];
    [self.slider3 addTarget:self action:@selector(Action:) forControlEvents:UIControlEventValueChanged];
    [self addSubview: self.slider3];
    
}
- (void)Action:(UISlider *)sender {
    self.backgroundColor = [UIColor colorWithRed:self.slider1.value green:self.slider2.value blue:self.slider3.value alpha:1.0];
}

@end
